package com.fuze.navi.config;

import com.fuze.navi.interceptor.TokenInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import javax.annotation.Resource;

/**
 * @author sepc_
 * @date 3/17/2021 09:29
 */
@Configuration
public class TokenInterceptorConfig extends WebMvcConfigurationSupport {

    @Resource
    private TokenInterceptor tokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册拦截器，要声明拦截器对象和要拦截的请求
        registry.addInterceptor(tokenInterceptor)
                //所有路径都被拦截
                .addPathPatterns("/**")
                // 排除请求
                .excludePathPatterns("/user/login", "/user/register","/testLoc")
        ;
    }
}
